package ma.ensao.egicom.bank.services.dao.imlementations;

import java.util.Map;

import ma.ensao.egicom.bank.services.dao.interfaces.CreditCardDao;
import ma.ensao.egicom.bank.services.dao.interfaces.HibernateDaoBaseImplementationPatch;
import ma.ensao.egicom.bank.services.model.Account;
import ma.ensao.egicom.bank.services.model.CreditCard;

/**
 * Implémentation de l'interface AccountDao.
 * @author MILHI Yassine (milhi.yassinee@gmail.com)
 */
public class CreditCardDaoImpl extends HibernateDaoBaseImplementationPatch implements CreditCardDao {

   
    /**
     * {@inheritDoc}
     */
    @Override
    public void createCreditCard(CreditCard crediCard) {
        save(crediCard);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public void deleteCreditCard(CreditCard crediCard) {
        delete(crediCard);

    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CreditCard getCreditCardById(Long idCard) {
        return load(idCard, CreditCard.class);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public Account getAccountOfCreditCard(String propertyName, Object value) {
        return getCreditCardByProperty(propertyName, value).getAccount();

    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CreditCard getCreditCardByProperty(String propertyName, Object value) {
        return (CreditCard) getOperationByProperty(propertyName, value, CreditCard.class, "creditCard").get(0);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    public CreditCard getCreditCardByProperties(Map<String, Object> properties) {
        return (CreditCard) getOperationByProperties(properties, CreditCard.class, "creditCard").get(0);
    }
}
